package com.lxw.study.structural.composite.case1;

import java.util.ArrayList;
import java.util.List;

/**
 * Composite节点
 */
public class Folder implements FileSystemComponent {
    private final String name;
    private final List<FileSystemComponent> components;

    public Folder(String name) {
        this.name = name;
        this.components = new ArrayList<>();
    }

    public void addComponent(FileSystemComponent component) {
        components.add(component);
    }

    @Override
    public void display() {
        System.out.println("Folder: " + name);
        for (FileSystemComponent component : components) {
            component.display();
        }
    }
}
